home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / tests / lrange.test < prev    next >
Encoding:
Text File  |  1994-12-18  |  2.5 KB  |  78 lines

  1. # Commands covered:  lrange
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # Copyright (c) 1994 Sun Microsystems, Inc.
  9. #
  10. # See the file "license.terms" for information on usage and redistribution
  11. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12. #
  13. # @(#) lrange.test 1.4 94/12/17 16:20:10
  14.  
  15. if {[string compare test [info procs test]] == 1} then {source defs}
  16.  
  17. test lrange-1.1 {range of list elements} {
  18.     lrange {a b c d} 1 2
  19. } {b c}
  20. test lrange-1.2 {range of list elements} {
  21.     lrange {a {bcd e {f g {}}} l14 l15 d} 1 1
  22. } {{bcd e {f g {}}}}
  23. test lrange-1.3 {range of list elements} {
  24.     lrange {a {bcd e {f g {}}} l14 l15 d} 3 end
  25. } {l15 d}
  26. test lrange-1.4 {range of list elements} {
  27.     lrange {a {bcd e {f g {}}} l14 l15 d} 4 10000
  28. } {d}
  29. test lrange-1.5 {range of list elements} {
  30.     lrange {a {bcd e {f g {}}} l14 l15 d} 4 3
  31. } {}
  32. test lrange-1.6 {range of list elements} {
  33.     lrange {a {bcd e {f g {}}} l14 l15 d} 10 11
  34. } {}
  35. test lrange-1.7 {range of list elements} {
  36.     lrange {a b c d e} -1 2
  37. } {a b c}
  38. test lrange-1.8 {range of list elements} {
  39.     lrange {a b c d e} -2 -1
  40. } {}
  41. test lrange-1.9 {range of list elements} {
  42.     lrange {a b c d e} -2 e
  43. } {a b c d e}
  44. test lrange-1.10 {range of list elements} {
  45.     lrange "a b\{c d" 1 2
  46. } "b\{c d"
  47. test lrange-1.11 {range of list elements} {
  48.     lrange "a b c d" end end
  49. } d
  50. test lrange-1.12 {range of list elements} {
  51.     lrange "a b c d" end 100000
  52. } d
  53. test lrange-1.13 {range of list elements} {
  54.     lrange "a b c d" e 3
  55. } d
  56. test lrange-1.14 {range of list elements} {
  57.     lrange "a b c d" end 2
  58. } {}
  59.  
  60. test lrange-2.1 {error conditions} {
  61.     list [catch {lrange a b} msg] $msg
  62. } {1 {wrong # args: should be "lrange list first last"}}
  63. test lrange-2.2 {error conditions} {
  64.     list [catch {lrange a b 6 7} msg] $msg
  65. } {1 {wrong # args: should be "lrange list first last"}}
  66. test lrange-2.3 {error conditions} {
  67.     list [catch {lrange a b 6} msg] $msg
  68. } {1 {expected integer but got "b"}}
  69. test lrange-2.4 {error conditions} {
  70.     list [catch {lrange a 0 enigma} msg] $msg
  71. } {1 {expected integer or "end" but got "enigma"}}
  72. test lrange-2.5 {error conditions} {
  73.     list [catch {lrange "a \{b c" 3 4} msg] $msg
  74. } {1 {unmatched open brace in list}}
  75. test lrange-2.6 {error conditions} {
  76.     list [catch {lrange "a b c \{ d e" 1 4} msg] $msg
  77. } {1 {unmatched open brace in list}}
  78.